﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>角色管理</title>
  <link href="http://g.alicdn.com/sj/dpl/1.5.1/css/sui.min.css" rel="stylesheet">
</head>
<body ms-controller="infoview">
  <div class="sui-container">

    <div class="sui-form form-horizontal sui-validate" >
        <div style="padding-bottom:10px;">
            搜索关键字： <input type="text" ms-duplex="searchkey" />
         <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetListData()">查询</a>
         <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADD('')" ms-if="top.model.HasAuth('ADD')">添加</a>
        </div>
         
      <table class="sui-table table-primary table-zebra">
  <thead>
    <tr>
      <th>角色名</th>
      <th>创建时间</th>
      <th style="width:150px;">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr ms-repeat-el="ListData">
      <td>{{el.RoleName}}</td>
      <td>{{el.CRTime|date('yyyy-MM-dd HH:mm:ss')}}</td>
      <td>
          <a href="javascript:void(0);" class="sui-btn btn-bordered btn-success" ms-click="ADD(el)" ms-if="top.model.HasAuth('EDIT')">编辑</a>
          <a href="javascript:void(0);" class="sui-btn btn-bordered btn-danger" ms-click="DEL(el)" ms-if="top.model.HasAuth('DEL')">删除</a>
      </td>
    </tr>
  </tbody>
</table>
        <div id="pageDiv"></div>

    </div> 
    
    
  </div>
    <script type="text/javascript" src="http://g.alicdn.com/sj/lib/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="http://g.alicdn.com/sj/dpl/1.5.1/js/sui.min.js"></script>
    <script src="/admin/js/avalon1.5.js"></script>
    <script src="/admin/js/ComFunJS.js?v=20170808"></script>
    
    <script type="text/javascript">
        var model = avalon.define({
            $id: "infoview",
            client: "",
            clientName: "",
            page: { pageindex: 1, pagesize: 10 },
            ListData: [],
            searchkey: "",
            GetListData: function () {
                model.ListData.clear();
                $.getJSON("/adapi/auth/rolelist", { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey }, function (r) {
                    if (r.error == "") {
                        model.ListData.clear();
                        model.ListData = r.result;
                        $("#pageDiv").pagination({  //分页容器
                            styleClass: ['sui-pagination'],  //分页样式
                            //showCtrl: false,
                            displayPage: 6,
                            itemsCount: r.total,
                            pageSize: model.page.pagesize,
                            onSelect: function (num) {
                                model.page.pageindex = num;
                                $.getJSON("/adapi/auth/rolelist", { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey }, function (r) {
                                    model.ListData.clear();
                                    model.ListData = r.result;
                                })
                            }
                        })

                        $('#pageDiv').pagination('updateItemsCount', r.total, 1);

                    }
                })

            },
            ADD: function (el) {
                if (el) {
                    top.ComFunJS.winShowForm("/admin/base/add.html?funcode=authrole&ID=" + el.ID, "修改");
                } else {
                    top.ComFunJS.winShowForm("/admin/base/add.html?funcode=authrole", "添加");
                }
            },
            DEL: function (el) {
                if (el) {
                    top.ComFunJS.winShowConfirm("<span style='color:red;'>确定要删除吗?<span>", function () {
                        $.getJSON("/adapi/auth/roledel/" + el.ID, function (r) {
                            if (r.error == "") {
                                top.ComFunJS.winShowMsg("删除成功");
                                model.ListData.remove(el);
                            }
                        })
                    })
                }
            }

        })
        avalon.ready(function () {
            
            model.GetListData();

        })
    </script>
</body>
</html>
